package com.hais1992.oneday.dao;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hais1992.oneday.R;
import com.hais1992.oneday.tools.StringUtil;

/**
 * 文章适配器
 * @author Hello_海生
 * @date 2014年5月21日
 */
public class ReviewAdapter extends BaseAdapter{
	private Context context;
	private LayoutInflater layoutInflater;
	private List<Map<String,Object>> list =null;
	
	public ReviewAdapter(Context context,List<Map<String,Object>> list) {
		this.context = context;
		layoutInflater = layoutInflater.from(context);
		this.list = list;
	}

	
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		System.out.println("*------------1----------------*");
		if(view==null){
			view = layoutInflater.inflate(R.layout.review_item, null);
		}
		System.out.println("*------------2----------------*");
		TextView userTv = (TextView) view.findViewById(R.id.userTv);
		TextView contentTv = (TextView) view.findViewById(R.id.contentTv);
		System.out.println("*------------3----------------*");
		userTv.setText(list.get(position).get("time").toString());
		System.out.println("*------------4----------------*");
		contentTv.setText(StringUtil.limitString(list.get(position).get("content").toString(), 57*2)+"...");
		System.out.println("*------------5----------------*");
		return view;
	}
	
}
